home *** CD-ROM | disk | FTP | other *** search
/ Macromedia Multimedia Showcase 5.1 / Macromedia - Multimedia Showcase 5.1 (Macromedia) (1996).ISO / pc / media / shared.dir / 02004_Script_Glossary Script < prev    next >
Text File  |  1996-03-28  |  5KB  |  170 lines

  1. -- Glossary Script
  2.  
  3. on InitGlossary
  4.   global GlossaryList
  5.   set GlossaryList = [ ]
  6.   global gGlossaryListSprite  -- sprite that contains the scrolling bitmap with all
  7.   set gGlossaryListSprite = 6 -- glossary items in a list
  8.   global gGlossHiliteSprite
  9.   set gGlossHiliteSprite = 7
  10.   global glossaryTextSprite
  11.   set glossaryTextSprite = 8
  12.   global deltaY -- how many pixels to vertically scroll the text bitmap
  13.   set deltaY = 24
  14.   global windowHeight
  15.   set windowHeight = 11 -- how many glossary items fit in single view of scrolling window
  16.   global textTopMargin, textLeftMargin, hiliteTopMargin, hiliteLeftMargin  
  17.   --  set textTopMargin = integer((the height of cast "glossary list")/2 - 142)
  18.   set textTopMargin = -99
  19.   set textLeftMargin = 75 + integer(the width of cast "glossary list"/2)  
  20.   set hiliteTopMargin = 194
  21.   set hiliteLeftMargin = integer(the width of cast "glossary hilite"/2)
  22.   global glossScroll
  23.   set glossScroll = 0  
  24. end InitGlossary
  25.  
  26. --
  27.  
  28. -- LaunchGlossary() is called from event database, upon entering the glossary screen
  29.  
  30. on LaunchGlossary
  31.   -- put "LaunchGlossary()"
  32.   global gNavObj
  33.   set firstBtn = the firstBtnSprite of gNavObj
  34.   repeat with i = firstBtn to firstBtn+3
  35.     set the lineSize of sprite i = 0
  36.   end repeat
  37.   ScrollToVisible()
  38.   DrawFields()
  39.   SetGlossaryText()
  40. end LaunchGLossary
  41.  
  42. --
  43.  
  44. on AddGlossaryExitScript
  45.   global gNavObj
  46.   Add (the exitQue of gNavObj), "CloseGlossary"
  47. end AddGlossaryExitScript
  48.  
  49. --
  50.  
  51. on CloseGlossary
  52.   -- put "CloseGlossary()"
  53.   global glossaryTextSprite
  54.   puppetSprite glossaryTextSprite, FALSE
  55.   -- AUT: now, store glossaryItemName so that you pre-load glossary to this item
  56. end CloseGlossary
  57.  
  58. --
  59.  
  60. on ScrollGlossaryUp
  61.   global glossScroll
  62.   if glossScroll>0 then
  63.     set glossScroll = glossScroll - 1
  64.     DrawFields()
  65.   else
  66.     beep
  67.   end if
  68. end ScrollGlossaryUp
  69.  
  70. --
  71.  
  72. on ScrollGlossaryDown
  73.   global glossScroll, lastItem, windowHeight  
  74.   if glossScroll < lastItem-windowHeight then
  75.     set glossScroll = glossScroll + 1
  76.     DrawFields()
  77.   else
  78.     beep
  79.   end if
  80. end ScrollGlossaryDown
  81.  
  82. --
  83.  
  84. on DrawFields
  85.   global glossScroll, textTopMargin, textLeftMargin, hiliteTopMargin, hiliteLeftMargin
  86.   global lastItem, gGlossaryListSprite, gGlossHiliteSprite, currentGlossaryItem, deltaY   
  87.   set the locV of sprite gGlossaryListSprite = textTopMargin + ¼
  88.       integer((lastItem-glossScroll)*deltaY)
  89.   set the locV of sprite gGlossHiliteSprite = ¼
  90.       integer(currentGlossaryItem*deltaY+textTopMargin+hiliteTopMargin) - glossScroll*deltaY
  91.   set the locH of sprite gGlossaryListSprite = textLeftMargin
  92.   set the locH of sprite gGlossHiliteSprite = hiliteLeftMargin
  93. end DrawFields
  94.  
  95. --
  96.  
  97. on ScrollToVisible
  98.   global currentGlossaryItem, glossScroll, windowHeight, lastItem
  99.   set glossScroll = min(currentGlossaryItem-1,(lastItem-windowHeight))
  100. end ScrollToVisible
  101.  
  102. --
  103.  
  104. on ClickGlossary
  105.   set clickY = the mouseV
  106.   global currentGlossaryItem, gGlossaryListSprite, textTopMargin, deltaY, glossScroll 
  107.   global GlossaryList, glossaryItemName
  108.   set myItem = integer((clickY-textTopMargin-3)/deltaY + glossScroll - 8)
  109.   global lastItem
  110.   if myItem = lastItem+1 then set myItem = lastItem
  111.   if myItem = 0 then set myItem = 1
  112.   set currentGlossaryItem = myItem
  113.   getAt GlossaryList, currentGlossaryItem
  114.   set glossaryItemName = the result
  115.   DrawFields()
  116.   SetGlossaryText()
  117. end ClickGlossary
  118.  
  119. --
  120.  
  121. on SetGlossaryText
  122.   global currentGlossaryItem, glossaryTextSprite, glossaryItemName
  123.   puppetSprite glossaryTextSprite, TRUE
  124.   set myCastName = "glossary:" & glossaryItemName
  125.   set the castNum of sprite glossaryTextSprite = cast myCastName
  126.   set the loc of sprite glossaryTextSprite = point(270,140)
  127.   updateStage
  128. end SetGlossaryText
  129.  
  130. --
  131.  
  132. on GoGlossary whichLabel
  133.   global GlossaryList, currentGlossaryItem, glossaryItemName
  134.   set glossaryItemName = string(value(whichLabel))
  135.   getOne GlossaryList, glossaryItemName
  136.   set currentGlossaryItem = the result
  137.   set GlossaryID = "80000" -- AUT: hardwired SceneID for glossary
  138.   global gNavObj
  139.   set the direction of gNavObj = #jump
  140.   LoadSeq(gNavObj, GlossaryID)
  141.   ChangeScene(gNavObj, GlossaryID)
  142. end GoGlossary
  143.  
  144.  
  145. --
  146.  
  147. on AddGlossaryItem whichItem
  148.   set whichItem = string(word 2 of whichItem)
  149.   set myLast = length(whichItem)
  150.   set whichItem = char 2 to myLast of whichItem
  151.   global GlossaryList
  152.   GetOne glossarylist, whichItem
  153.   if the result = 0 then -- unique item that does not exist in glossary
  154.     add GlossaryList, whichItem
  155.   end if
  156. end AddGlossaryItem
  157.  
  158. --
  159.  
  160. on PrepGlossaryList
  161.   global GlossaryList, lastItem
  162.   sort GlossaryList 
  163.   -- put GlossaryList
  164.   set lastItem = count(GlossaryList)
  165.   global currentGlossaryItem
  166.   set currentGlossaryItem = 1
  167.   global glossaryItemName
  168.   getAt GlossaryList, 1  
  169.   set glossaryItemName = the result  
  170. end PrepGlossaryList